//
//  GuessYouLikeView.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/27.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "GuessYouLikeView.h"
#import "CommonMacro.h"
#import "GuessYouLikeCell.h"
@implementation GuessYouLikeView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self createSubview];
    }
    return self;
}

- (void)createSubview
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(self.frame.size.width/2, self.frame.size.height/2);
    
    
    self.collectoinView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH , SCREEN_HEIGHT*0.9) collectionViewLayout:flowLayout];
//    self.collectoinView.backgroundColor = [UIColor redColor];
    self.collectoinView.backgroundColor = UIColorWithRGBA(255, 255, 255, 1);
    [self.collectoinView registerClass:[GuessYouLikeCell class] forCellWithReuseIdentifier:@"GuessYouLikeCell"];
    [self addSubview:self.collectoinView];
    self.collectoinView.delegate = self;
    self.collectoinView.dataSource = self;
    
}

//定义展示的UICollectionViewCell的个数
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 8;
}
//定义展示的Section的个数
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
//每个UICollectionView展示的内容
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * CellIdentifier = @"GuessYouLikeCell";
    GuessYouLikeCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    
//    cell.backgroundColor = [UIColor redColor];
    return cell;
}
#pragma mark --UICollectionViewDelegateFlowLayout
//定义每个UICollectionView 的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(SCREEN_WIDTH*0.484, SCREEN_WIDTH*0.5);
}

#pragma mark-- 点击后执行
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if ([self.clickCellEnterDelegate respondsToSelector:@selector(clickCellEnterOtherView:)]) {
        [self.clickCellEnterDelegate clickCellEnterOtherView:indexPath.row];
    }
}


//返回头headerView的大小
//-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
//    CGSize size={320,45};
//    return size;
//}

@end
